package com.test.java;

import java.util.Scanner;

/**
 * 3485djDkxh4hhGE
 * 2984akDfkkkkggEdsb    第一对大写字母==星期；第二对大写字母或数字==时
 * s&hgsfdk
 * d&Hyscvnm    第一对字母==分
 * =============================================================
 * Version          Author          Date            Description
 * 1.0              白建         2017/12/14             创建
 * =============================================================
 */
public class Java_5
{

    private static final short SIZE = 4;

    private static String[] input;

    public static void main(String[] args)
    {

        init();
        process();
    }

    private static void init()
    {

        input = new String[SIZE];
        Scanner scanner = new Scanner(System.in);
        for (int i = 0; i < SIZE; i++)
        {
            input[i] = scanner.nextLine();
        }
    }

    private static void process()
    {

        int i = 0;
        for (; i < (input[0].length() < input[1].length() ? input[0].length() : input[1].length()); i++)
        {
            boolean flag = false;
            if (input[0].charAt(i) == input[1].charAt(i))
            {
                switch (input[0].charAt(i))
                {
                case 'A':
                    System.out.print("MON");
                    flag = true;
                    break;
                case 'B':
                    System.out.print("TUE");
                    flag = true;
                    break;
                case 'C':
                    System.out.print("WED");
                    flag = true;
                    break;
                case 'D':
                    System.out.print("THU");
                    flag = true;
                    break;
                case 'E':
                    System.out.print("FRI");
                    flag = true;
                    break;
                case 'F':
                    System.out.print("SAT");
                    flag = true;
                    break;
                case 'G':
                    System.out.print("SUN");
                    flag = true;
                    break;
                default:
                    break;
                }
            }
            if (flag)
            {
                i++;
                break;
            }
        }

        for (; i < (input[0].length() < input[1].length() ? input[0].length() : input[1].length()); i++)
        {
            if (input[0].charAt(i) == input[1].charAt(i))
            {
                //todo:char转int后的结果
                int hour = Character.getNumericValue(input[0].charAt(i));
                if (hour <= 9)
                {
                    System.out.print(" 0" + hour);
                    break;
                }
                else
                {
                    System.out.print(" " + hour);
                    break;
                }
            }
        }

        for (int j = 0; j < (input[2].length() < input[3].length() ? input[2].length() : input[3].length()); j++)
        {
            if (input[2].charAt(j) == input[3].charAt(j))
            {
                int minute = Character.getNumericValue(input[2].charAt(j));
                if (minute > 9)
                {
                    if (j <= 9)
                    {
                        System.out.print(":0" + j);
                        break;
                    }
                    else
                    {
                        System.out.print(":" + j);
                        break;
                    }
                }
            }
        }
    }
}
